package com.project.grenting.service.order.impl;

import com.project.grenting.dao.order.OrderDao;
import com.project.grenting.pojo.Order;
import com.project.grenting.service.order.OrderService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderDao orderDao ;


    @Override
    public List<Order> getAllOrders() {
        return orderDao.getAllOrders() ;
    }



    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int addOrder(Order order) {
        int success = 0 ;

        //先将用户加入用户表中
        orderDao.addOrder(order) ;
  /*      System.out.println(order.getId());
        //  //循环将用户选择的角色加入中间表*/

        success = 1 ;

        return success ;
    }
}
  /*  @Override
    public Order getOrderById(int id) {
        return orderDao.getOrderById(id);
    }
*/
 /*   @Override
    public Order getOrderById(int id) {
        return orderDao.getOrderById(id);
    }*/

  /* @Override
    public User getUserByLoginCode(String loginCode) {
        return userDao.getUserByLoginCode(loginCode);
    }
*/
